<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="/WEB-INF/esquema/plantillasimple.xhtml">

	<ui:define name="body">
		<h:form>
			<a4j:keepAlive beanName="usersHelper"/>
			<div align="center">
				<h3>Mantenimiento de Usuarios</h3>
				<br />
				<rich:separator/>
				<br />
				<rich:dataTable id="dtUsers" value="#{usersHelper.users}" var="user" rowKeyVar="row">
					<rich:column>
						<f:facet name="header">Usuario</f:facet>
						<h:outputText value="#{user.userName}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">Primer nombre</f:facet>
						<h:outputText value="#{user.party.firstName1}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">Primer apellido</f:facet>
						<h:outputText value="#{user.party.lastName1}" />
					</rich:column>
					<rich:column>
						<f:facet name="header"></f:facet>
						<a4j:commandLink value="Editar" oncomplete="#{rich:component('editUsuario')}.show();">
							<f:setPropertyActionListener value="#{user}" target="#{userHelper.selected}" />
							<f:setPropertyActionListener value="#{row}" target="#{usersHelper.currentRow}" />
						</a4j:commandLink>
					</rich:column>
					<rich:column>
						<f:facet name="header"></f:facet>
						<a4j:commandLink value="Borrar" action="#{usersHelper.deleteSelectedUser}" reRender="dtUsers">
							<f:setPropertyActionListener value="#{row}" target="#{usersHelper.currentRow}" />
						</a4j:commandLink>
					</rich:column>
				</rich:dataTable>
			</div>
		</h:form>
		
		<rich:modalPanel id="editUsuario" width="400" height="300">
			<f:facet name="header">
				<h:outputText value="Edicion de datos del Usuario"/>
			</f:facet>
			
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/img/close.png" styleClass="hidelink"
						id="hideEditDataPanel" />
					<rich:componentControl for="editDataPanelToolbox" attachTo="hideEditDataPanel"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			
			<h:form>
				<h:messages />
				<h:panelGrid columns="2">
					<h:outputText value="Contrasena" />
					<h:inputSecret value="#{userHelper.password}" />
					
					<h:outputText value="Confirmar contrasena" />
					<h:inputSecret value="#{userHelper.confPassword}" />
					
					<h:outputText value="Activo?" />
					<h:selectBooleanCheckbox value="#{userHelper.selected.active}" />
				</h:panelGrid>
				<br />
				<h:panelGrid columns="2">
					<a4j:commandButton value="Aceptar" action="#{userHelper.applyChange}" oncomplete="if (#{facesContext.maximumSeverity == null}) #{rich:component('editUsuario')}.hide();"/>
					<a4j:commandButton value="Cancelar" ajaxSingle="true" oncomplete="#{rich:component('editUsuario')}.hide();"/>
				</h:panelGrid>
			</h:form>
		</rich:modalPanel>
	</ui:define>
</ui:composition>
	
